//功能：暴露接口
import config from "@/common/config.js"
export const myRequest = (url = '', data, type = 'GET', header = {}) => {
	return new Promise((resolve, reject) => {
		var token = ''
		if (uni.getStorageSync('token')) {
			var token = uni.getStorageSync('token')
		}
		uni
			.request({
				method: type,
				url: config.baseUrl + url,
				data: data,
				header: {
					Authorization: `Bearer ${token}`,
				},
				dataType: 'json',
			})
			.then((response) => {
				setTimeout(function () {
					uni.hideLoading()
				}, 200)
				let [error, res] = response
				resolve(res.data)

			})
			.catch((error) => {
				reject(error)
			})
	})
}
